<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>texpane.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="closure_goog_ui_equation_texpane.js.html">texpane.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2008 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>goog.provide(&#39;goog.ui.equation.TexPane&#39;);
<a name="line16"></a>
<a name="line17"></a>goog.require(&#39;goog.Timer&#39;);
<a name="line18"></a>goog.require(&#39;goog.dom&#39;);
<a name="line19"></a>goog.require(&#39;goog.dom.TagName&#39;);
<a name="line20"></a>goog.require(&#39;goog.dom.selection&#39;);
<a name="line21"></a>goog.require(&#39;goog.events&#39;);
<a name="line22"></a>goog.require(&#39;goog.events.EventType&#39;);
<a name="line23"></a>goog.require(&#39;goog.events.InputHandler&#39;);
<a name="line24"></a>goog.require(&#39;goog.string&#39;);
<a name="line25"></a>goog.require(&#39;goog.style&#39;);
<a name="line26"></a>goog.require(&#39;goog.ui.Component&#39;);
<a name="line27"></a>goog.require(&#39;goog.ui.equation.ChangeEvent&#39;);
<a name="line28"></a>goog.require(&#39;goog.ui.equation.EditorPane&#39;);
<a name="line29"></a>goog.require(&#39;goog.ui.equation.ImageRenderer&#39;);
<a name="line30"></a>goog.require(&#39;goog.ui.equation.PaletteManager&#39;);
<a name="line31"></a>
<a name="line32"></a>
<a name="line33"></a>
<a name="line34"></a>/**
<a name="line35"></a> * User interface for TeX equation editor tab pane.
<a name="line36"></a> * @param {Object} context The context this Tex editor pane runs in.
<a name="line37"></a> * @param {string} helpUrl The help link URL.
<a name="line38"></a> * @param {goog.dom.DomHelper=} opt_domHelper Optional DOM helper.
<a name="line39"></a> * @constructor
<a name="line40"></a> * @extends {goog.ui.equation.EditorPane}
<a name="line41"></a> */
<a name="line42"></a>goog.ui.equation.TexPane = function(
<a name="line43"></a>    context, helpUrl, opt_domHelper) {
<a name="line44"></a>  goog.ui.equation.EditorPane.call(this, opt_domHelper);
<a name="line45"></a>
<a name="line46"></a>  this.setHelpUrl(helpUrl);
<a name="line47"></a>
<a name="line48"></a>  /**
<a name="line49"></a>   * The palette manager instance.
<a name="line50"></a>   * @type {goog.ui.equation.PaletteManager}
<a name="line51"></a>   * @private
<a name="line52"></a>   */
<a name="line53"></a>  this.paletteManager_ =
<a name="line54"></a>      /** @type {goog.ui.equation.PaletteManager} */(
<a name="line55"></a>      context.paletteManager);
<a name="line56"></a>};
<a name="line57"></a>goog.inherits(goog.ui.equation.TexPane,
<a name="line58"></a>    goog.ui.equation.EditorPane);
<a name="line59"></a>
<a name="line60"></a>
<a name="line61"></a>/**
<a name="line62"></a> * The CSS class name for the preview container.
<a name="line63"></a> * @type {string}
<a name="line64"></a> */
<a name="line65"></a>goog.ui.equation.TexPane.PREVIEW_CONTAINER_CSS_CLASS =
<a name="line66"></a>    &#39;ee-preview-container&#39;;
<a name="line67"></a>
<a name="line68"></a>
<a name="line69"></a>/**
<a name="line70"></a> * The CSS class name for section titles.
<a name="line71"></a> * @type {string}
<a name="line72"></a> */
<a name="line73"></a>goog.ui.equation.TexPane.SECTION_TITLE_CSS_CLASS =
<a name="line74"></a>    &#39;ee-section-title&#39;;
<a name="line75"></a>
<a name="line76"></a>
<a name="line77"></a>/**
<a name="line78"></a> * The CSS class name for section titles that float left.
<a name="line79"></a> * @type {string}
<a name="line80"></a> */
<a name="line81"></a>goog.ui.equation.TexPane.SECTION_TITLE_FLOAT_CSS_CLASS =
<a name="line82"></a>    &#39;ee-section-title-floating&#39;;
<a name="line83"></a>
<a name="line84"></a>
<a name="line85"></a>/**
<a name="line86"></a> * The CSS id name for the link to &quot;Learn more&quot;.
<a name="line87"></a> * @type {string}
<a name="line88"></a> */
<a name="line89"></a>goog.ui.equation.TexPane.SECTION_LEARN_MORE_CSS_ID =
<a name="line90"></a>    &#39;ee-section-learn-more&#39;;
<a name="line91"></a>
<a name="line92"></a>
<a name="line93"></a>/**
<a name="line94"></a> * The CSS class name for the Tex editor.
<a name="line95"></a> * @type {string}
<a name="line96"></a> */
<a name="line97"></a>goog.ui.equation.TexPane.TEX_EDIT_CSS_CLASS = &#39;ee-tex&#39;;
<a name="line98"></a>
<a name="line99"></a>
<a name="line100"></a>/**
<a name="line101"></a> * The CSS class name for the preview container.
<a name="line102"></a> * @type {string}
<a name="line103"></a> */
<a name="line104"></a>goog.ui.equation.TexPane.WARNING_CLASS =
<a name="line105"></a>    &#39;ee-warning&#39;;
<a name="line106"></a>
<a name="line107"></a>
<a name="line108"></a>/**
<a name="line109"></a> * The content div of the TeX editor.
<a name="line110"></a> * @type {Element}
<a name="line111"></a> * @private
<a name="line112"></a> */
<a name="line113"></a>goog.ui.equation.TexPane.prototype.texEditorElement_ = null;
<a name="line114"></a>
<a name="line115"></a>
<a name="line116"></a>/**
<a name="line117"></a> * The container div for the server-generated image of the equation.
<a name="line118"></a> * @type {Element}
<a name="line119"></a> * @private
<a name="line120"></a> */
<a name="line121"></a>goog.ui.equation.TexPane.prototype.previewContainer_;
<a name="line122"></a>
<a name="line123"></a>
<a name="line124"></a>/**
<a name="line125"></a> * An inner container used to layout all the elements in Tex Editor.
<a name="line126"></a> * @type {Element}
<a name="line127"></a> * @private
<a name="line128"></a> */
<a name="line129"></a>goog.ui.equation.TexPane.prototype.innerContainer_;
<a name="line130"></a>
<a name="line131"></a>
<a name="line132"></a>/**
<a name="line133"></a> * The textarea for free form TeX.
<a name="line134"></a> * @type {Element}
<a name="line135"></a> * @private
<a name="line136"></a> */
<a name="line137"></a>goog.ui.equation.TexPane.prototype.texEdit_;
<a name="line138"></a>
<a name="line139"></a>
<a name="line140"></a>/**
<a name="line141"></a> * The input handler for Tex editor.
<a name="line142"></a> * @type {goog.events.InputHandler}
<a name="line143"></a> * @private
<a name="line144"></a> */
<a name="line145"></a>goog.ui.equation.TexPane.prototype.texInputHandler_;
<a name="line146"></a>
<a name="line147"></a>
<a name="line148"></a>/**
<a name="line149"></a> * The last text that was renderred as an image.
<a name="line150"></a> * @type {string}
<a name="line151"></a> * @private
<a name="line152"></a> */
<a name="line153"></a>goog.ui.equation.TexPane.prototype.lastRenderredText_ = &#39;&#39;;
<a name="line154"></a>
<a name="line155"></a>
<a name="line156"></a>/**
<a name="line157"></a> * A sequence number for text change events. Used to delay drawing
<a name="line158"></a> * until the user paused typing.
<a name="line159"></a> * @type {number}
<a name="line160"></a> * @private
<a name="line161"></a> */
<a name="line162"></a>goog.ui.equation.TexPane.prototype.changeSequence_ = 0;
<a name="line163"></a>
<a name="line164"></a>
<a name="line165"></a>/** @override */
<a name="line166"></a>goog.ui.equation.TexPane.prototype.createDom = function() {
<a name="line167"></a>
<a name="line168"></a>  /** @desc Title for TeX editor tab in the equation editor dialog. */
<a name="line169"></a>  var MSG_EE_TEX_EQUATION = goog.getMsg(&#39;TeX Equation&#39;);
<a name="line170"></a>
<a name="line171"></a>  /** @desc Title for equation preview image in the equation editor dialog. */
<a name="line172"></a>  var MSG_EE_TEX_PREVIEW = goog.getMsg(&#39;Preview&#39;);
<a name="line173"></a>
<a name="line174"></a>  /** @desc Link text that leads to an info page about the equation dialog. */
<a name="line175"></a>  var MSG_EE_LEARN_MORE = goog.getMsg(&#39;Learn more&#39;);
<a name="line176"></a>
<a name="line177"></a>  var domHelper = this.dom_;
<a name="line178"></a>  var innerContainer;
<a name="line179"></a>  var texEditorEl = domHelper.createDom(goog.dom.TagName.DIV,
<a name="line180"></a>      {&#39;style&#39;: &#39;display: none;&#39;},
<a name="line181"></a>      domHelper.createDom(goog.dom.TagName.SPAN,
<a name="line182"></a>          {&#39;class&#39;:
<a name="line183"></a>            goog.ui.equation.TexPane.SECTION_TITLE_CSS_CLASS +
<a name="line184"></a>            &#39; &#39; +
<a name="line185"></a>            goog.ui.equation.TexPane.SECTION_TITLE_FLOAT_CSS_CLASS},
<a name="line186"></a>          MSG_EE_TEX_EQUATION),
<a name="line187"></a>      this.getHelpUrl() ?
<a name="line188"></a>      domHelper.createDom(goog.dom.TagName.A,
<a name="line189"></a>      {&#39;id&#39;:
<a name="line190"></a>            goog.ui.equation.TexPane.SECTION_LEARN_MORE_CSS_ID,
<a name="line191"></a>        &#39;target&#39;: &#39;_blank&#39;, &#39;href&#39;: this.getHelpUrl()},
<a name="line192"></a>      MSG_EE_LEARN_MORE) : null,
<a name="line193"></a>      domHelper.createDom(goog.dom.TagName.DIV,
<a name="line194"></a>          {&#39;style&#39;: &#39;clear: both;&#39;}),
<a name="line195"></a>      innerContainer = this.innerContainer_ =
<a name="line196"></a>          domHelper.createDom(goog.dom.TagName.DIV,
<a name="line197"></a>          {&#39;style&#39;: &#39;position: relative&#39;}));
<a name="line198"></a>
<a name="line199"></a>  // Create menu palette.
<a name="line200"></a>  var menuPalette =
<a name="line201"></a>      this.paletteManager_.setActive(
<a name="line202"></a>      goog.ui.equation.Palette.Type.MENU);
<a name="line203"></a>
<a name="line204"></a>  // Render the menu palette.
<a name="line205"></a>  menuPalette.render(innerContainer);
<a name="line206"></a>
<a name="line207"></a>  innerContainer.appendChild(domHelper.createDom(goog.dom.TagName.DIV,
<a name="line208"></a>      {&#39;style&#39;: &#39;clear:both&#39;}));
<a name="line209"></a>
<a name="line210"></a>  var texEdit = this.texEdit_ = domHelper.createDom(&#39;textarea&#39;,
<a name="line211"></a>      {&#39;class&#39;: goog.ui.equation.TexPane.TEX_EDIT_CSS_CLASS,
<a name="line212"></a>        &#39;dir&#39;: &#39;ltr&#39;});
<a name="line213"></a>
<a name="line214"></a>  innerContainer.appendChild(texEdit);
<a name="line215"></a>
<a name="line216"></a>  innerContainer.appendChild(
<a name="line217"></a>      domHelper.createDom(goog.dom.TagName.DIV,
<a name="line218"></a>          {&#39;class&#39;:
<a name="line219"></a>            goog.ui.equation.TexPane.SECTION_TITLE_CSS_CLASS},
<a name="line220"></a>          MSG_EE_TEX_PREVIEW));
<a name="line221"></a>
<a name="line222"></a>  var previewContainer = this.previewContainer_ = domHelper.createDom(
<a name="line223"></a>      goog.dom.TagName.DIV,
<a name="line224"></a>      {&#39;class&#39;:
<a name="line225"></a>            goog.ui.equation.TexPane.PREVIEW_CONTAINER_CSS_CLASS});
<a name="line226"></a>
<a name="line227"></a>  innerContainer.appendChild(previewContainer);
<a name="line228"></a>
<a name="line229"></a>  this.setElementInternal(texEditorEl);
<a name="line230"></a>};
<a name="line231"></a>
<a name="line232"></a>
<a name="line233"></a>/** @override */
<a name="line234"></a>goog.ui.equation.TexPane.prototype.enterDocument = function() {
<a name="line235"></a>  this.texInputHandler_ = new goog.events.InputHandler(this.texEdit_);
<a name="line236"></a>
<a name="line237"></a>  // Listen to changes in the edit box to redraw equation.
<a name="line238"></a>  goog.events.listen(this.texInputHandler_,
<a name="line239"></a>      goog.events.InputHandler.EventType.INPUT,
<a name="line240"></a>      this.handleTexChange_, false, this);
<a name="line241"></a>
<a name="line242"></a>  // Add a keyup listener for Safari that does not support the INPUT event,
<a name="line243"></a>  // and for users pasting with ctrl+v, which does not generate an INPUT event
<a name="line244"></a>  // in some browsers.
<a name="line245"></a>  this.getHandler().listen(
<a name="line246"></a>      this.texEdit_, goog.events.EventType.KEYDOWN, this.handleTexChange_);
<a name="line247"></a>
<a name="line248"></a>  // Listen to the action event on the active palette.
<a name="line249"></a>  this.getHandler().listen(this.paletteManager_,
<a name="line250"></a>      goog.ui.equation.PaletteEvent.Type.ACTION,
<a name="line251"></a>      this.handlePaletteAction_, false, this);
<a name="line252"></a>};
<a name="line253"></a>
<a name="line254"></a>
<a name="line255"></a>/** @override */
<a name="line256"></a>goog.ui.equation.TexPane.prototype.setVisible = function(visible) {
<a name="line257"></a>  goog.base(this, &#39;setVisible&#39;, visible);
<a name="line258"></a>  if (visible) {
<a name="line259"></a>    goog.Timer.callOnce(this.focusTexEdit_, 0, this);
<a name="line260"></a>  }
<a name="line261"></a>};
<a name="line262"></a>
<a name="line263"></a>
<a name="line264"></a>/**
<a name="line265"></a> * Sets the focus to the TeX edit box.
<a name="line266"></a> * @private
<a name="line267"></a> */
<a name="line268"></a>goog.ui.equation.TexPane.prototype.focusTexEdit_ = function() {
<a name="line269"></a>  this.texEdit_.focus();
<a name="line270"></a>  goog.dom.selection.setCursorPosition(this.texEdit_,
<a name="line271"></a>      this.texEdit_.value.length);
<a name="line272"></a>};
<a name="line273"></a>
<a name="line274"></a>
<a name="line275"></a>/**
<a name="line276"></a> * Handles input change within the TeX textarea.
<a name="line277"></a> * @private
<a name="line278"></a> */
<a name="line279"></a>goog.ui.equation.TexPane.prototype.handleEquationChange_ = function() {
<a name="line280"></a>  var text = this.getEquation();
<a name="line281"></a>  if (text == this.lastRenderredText_) {
<a name="line282"></a>    return; // No change, no need to re-draw
<a name="line283"></a>  }
<a name="line284"></a>
<a name="line285"></a>  this.lastRenderredText_ = text;
<a name="line286"></a>  var isEquationValid =
<a name="line287"></a>      !goog.ui.equation.ImageRenderer.isEquationTooLong(text);
<a name="line288"></a>
<a name="line289"></a>  // Dispatch change so that dialog might update the state of its buttons.
<a name="line290"></a>  this.dispatchEvent(
<a name="line291"></a>      new goog.ui.equation.ChangeEvent(
<a name="line292"></a>      isEquationValid));
<a name="line293"></a>
<a name="line294"></a>  var container = this.previewContainer_;
<a name="line295"></a>  var dom = goog.dom.getDomHelper(container);
<a name="line296"></a>  dom.removeChildren(container);
<a name="line297"></a>
<a name="line298"></a>  if (text) {
<a name="line299"></a>    var childNode;
<a name="line300"></a>    if (isEquationValid) {
<a name="line301"></a>      // Show equation image.
<a name="line302"></a>
<a name="line303"></a>      var imgSrc = goog.ui.equation.ImageRenderer.getImageUrl(text);
<a name="line304"></a>      childNode = dom.createDom(goog.dom.TagName.IMG, {&#39;src&#39;: imgSrc});
<a name="line305"></a>    } else {
<a name="line306"></a>      // Show a warning message.
<a name="line307"></a>
<a name="line308"></a>      /**
<a name="line309"></a>       * @desc A warning message shown when equation the user entered is too
<a name="line310"></a>       *     long to display.
<a name="line311"></a>       */
<a name="line312"></a>      var MSG_EE_TEX_EQUATION_TOO_LONG =
<a name="line313"></a>          goog.getMsg(&#39;Equation is too long&#39;);
<a name="line314"></a>
<a name="line315"></a>      childNode = dom.createDom(goog.dom.TagName.DIV,
<a name="line316"></a>          {&#39;class&#39;: goog.ui.equation.TexPane.WARNING_CLASS},
<a name="line317"></a>          MSG_EE_TEX_EQUATION_TOO_LONG);
<a name="line318"></a>    }
<a name="line319"></a>    dom.appendChild(container, childNode);
<a name="line320"></a>  }
<a name="line321"></a>};
<a name="line322"></a>
<a name="line323"></a>
<a name="line324"></a>/**
<a name="line325"></a> * Handles a change to the equation text.
<a name="line326"></a> * Queues a request to handle input change within the TeX textarea.
<a name="line327"></a> * Refreshing the image is done only after a short timeout, to combine
<a name="line328"></a> * fast typing events into one draw.
<a name="line329"></a> * @param {goog.events.Event} e The keyboard event.
<a name="line330"></a> * @private
<a name="line331"></a> */
<a name="line332"></a>goog.ui.equation.TexPane.prototype.handleTexChange_ = function(e) {
<a name="line333"></a>  this.changeSequence_++;
<a name="line334"></a>  goog.Timer.callOnce(
<a name="line335"></a>      goog.bind(this.handleTexChangeTimer_, this, this.changeSequence_),
<a name="line336"></a>      500);
<a name="line337"></a>};
<a name="line338"></a>
<a name="line339"></a>
<a name="line340"></a>/**
<a name="line341"></a> * Handles a timer timeout on delayed text change redraw.
<a name="line342"></a> * @param {number} seq The change sequence number when the timer started.
<a name="line343"></a> * @private
<a name="line344"></a> */
<a name="line345"></a>goog.ui.equation.TexPane.prototype.handleTexChangeTimer_ =
<a name="line346"></a>    function(seq) {
<a name="line347"></a>  // Draw only if this was the last change. If not, just wait for the last.
<a name="line348"></a>  if (seq == this.changeSequence_) {
<a name="line349"></a>    this.handleEquationChange_();
<a name="line350"></a>  }
<a name="line351"></a>};
<a name="line352"></a>
<a name="line353"></a>
<a name="line354"></a>/**
<a name="line355"></a> * Handles an action generated by a palette click.
<a name="line356"></a> * @param {goog.ui.equation.PaletteEvent} e The event object.
<a name="line357"></a> * @private
<a name="line358"></a> */
<a name="line359"></a>goog.ui.equation.TexPane.prototype.handlePaletteAction_ = function(e) {
<a name="line360"></a>  var palette = e.getPalette();
<a name="line361"></a>  var paletteManager = this.paletteManager_;
<a name="line362"></a>  var activePalette = paletteManager.getActive();
<a name="line363"></a>  var texEdit = this.texEdit_;
<a name="line364"></a>
<a name="line365"></a>  // This is a click on the menu palette.
<a name="line366"></a>  if (palette.getType() == goog.ui.equation.Palette.Type.MENU) {
<a name="line367"></a>    var idx = palette.getHighlightedIndex();
<a name="line368"></a>    var action = (idx != -1) ? palette.getAction(idx) : null;
<a name="line369"></a>
<a name="line370"></a>    // Current palette is not menu.  This means there&#39;s a palette popping up.
<a name="line371"></a>    if (activePalette != palette &amp;&amp; activePalette.getType() == action) {
<a name="line372"></a>
<a name="line373"></a>      // Deactivate the palette.
<a name="line374"></a>      paletteManager.deactivateNow();
<a name="line375"></a>      return;
<a name="line376"></a>    }
<a name="line377"></a>
<a name="line378"></a>    // We are clicking on the menu palette and there&#39;s no sub palette opening.
<a name="line379"></a>    // Then we just open the one corresponding to the item under the mouse.
<a name="line380"></a>    if (action) {
<a name="line381"></a>      var subPalette = this.paletteManager_.setActive(
<a name="line382"></a>          /** @type {goog.ui.equation.Palette.Type} */ (action));
<a name="line383"></a>      if (!subPalette.getElement()) {
<a name="line384"></a>        subPalette.render(this.innerContainer_);
<a name="line385"></a>      }
<a name="line386"></a>      var el = subPalette.getElement();
<a name="line387"></a>      goog.style.setPosition(el, 0, - el.clientHeight);
<a name="line388"></a>    }
<a name="line389"></a>  } else {
<a name="line390"></a>    activePalette = this.paletteManager_.getActive();
<a name="line391"></a>    var action = activePalette.getAction(activePalette.getHighlightedIndex());
<a name="line392"></a>
<a name="line393"></a>    // If the click is on white space in the palette, do nothing.
<a name="line394"></a>    if (!action) {
<a name="line395"></a>      return;
<a name="line396"></a>    }
<a name="line397"></a>
<a name="line398"></a>    // Do actual insert async because IE8 does not move the selection
<a name="line399"></a>    // position and inserts in the wrong place if called in flow.
<a name="line400"></a>    // See bug 2066876
<a name="line401"></a>    goog.Timer.callOnce(goog.bind(this.insert_, this, action + &#39; &#39;), 0);
<a name="line402"></a>  }
<a name="line403"></a>
<a name="line404"></a>  // Let the tex editor always catch the focus.
<a name="line405"></a>  texEdit.focus();
<a name="line406"></a>};
<a name="line407"></a>
<a name="line408"></a>
<a name="line409"></a>/**
<a name="line410"></a> * Inserts text into the equation at the current cursor position.
<a name="line411"></a> * Moves the cursor to after the inserted text.
<a name="line412"></a> * @param {string} text Text to insert.
<a name="line413"></a> * @private
<a name="line414"></a> */
<a name="line415"></a>goog.ui.equation.TexPane.prototype.insert_ = function(text) {
<a name="line416"></a>  var texEdit = this.texEdit_;
<a name="line417"></a>  var pos = goog.dom.selection.getStart(texEdit);
<a name="line418"></a>  var equation = texEdit[&#39;value&#39;];
<a name="line419"></a>  equation = equation.substring(0, pos) + text + equation.substring(pos);
<a name="line420"></a>  texEdit[&#39;value&#39;] = equation;
<a name="line421"></a>  goog.dom.selection.setCursorPosition(texEdit, pos + text.length);
<a name="line422"></a>  this.handleEquationChange_();
<a name="line423"></a>};
<a name="line424"></a>
<a name="line425"></a>
<a name="line426"></a>/** @override */
<a name="line427"></a>goog.ui.equation.TexPane.prototype.getEquation = function() {
<a name="line428"></a>  return this.texEdit_[&#39;value&#39;];
<a name="line429"></a>};
<a name="line430"></a>
<a name="line431"></a>
<a name="line432"></a>/** @override */
<a name="line433"></a>goog.ui.equation.TexPane.prototype.setEquation =
<a name="line434"></a>    function(equation) {
<a name="line435"></a>  this.texEdit_[&#39;value&#39;] = equation;
<a name="line436"></a>  this.handleEquationChange_();
<a name="line437"></a>};
<a name="line438"></a>
<a name="line439"></a>
<a name="line440"></a>/** @override */
<a name="line441"></a>goog.ui.equation.TexPane.prototype.disposeInternal = function() {
<a name="line442"></a>  this.texInputHandler_.dispose();
<a name="line443"></a>  this.paletteManager_ = null;
<a name="line444"></a>  goog.base(this, &#39;disposeInternal&#39;);
<a name="line445"></a>};
</pre>


</body>
</html>
